﻿using Serilog.Enrichers.Sensitive;
using System.Text.RegularExpressions;

namespace Shared.Service.Logging.Serilog
{
    public class LogMobileMasking : RegexMaskingOperator
    {
        public LogMobileMasking() : base(@"\b1[23456789]\d{9}\b")
        {
        }

        protected override string PreprocessMask(string mask, Match match)
        {
            return Regex.Replace(match.Value, "(\\d{3})\\d{6}(\\d{2})", $"$1{mask.PadRight(6, mask.ToCharArray()[0])}$2");
        }
    }
}
